<template>
    <div style="margin-top: 20px;">
        <el-row>
            <el-col :md="9" :offset="7">
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="180px" class="demo-ruleForm">
                    <el-form-item
                        label="运营商名称："
                    >
                        <el-input v-model="ruleForm.name" auto-complete="off" aria-placeholder="wilson电信流量池" disabled></el-input>
                    </el-form-item>
                    <el-form-item
                        label="计费方式："
                    >
                        <el-radio-group v-model="ruleForm.jifei">
                            <el-radio :label="1">前向</el-radio>
                            <el-radio :label="2">后向</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item
                        label="流量资费(元/GB)："
                        prop="fee"
                    >
                        <el-input v-model="ruleForm.fee" auto-complete="off" aria-placeholder="元/GB" ></el-input>
                    </el-form-item>
                    <el-form-item
                        label="超额流量资费(元/GB)："
                        prop="chaofee"
                        v-show="ruleForm.jifei == '2'"
                    >
                        <el-input v-model="ruleForm.chaofee" auto-complete="off" aria-placeholder="元/GB"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
                        <el-button @click="resetForm('ruleForm')">取消</el-button>
                    </el-form-item>
                </el-form>
            </el-col>
        </el-row>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                ruleForm: {
                    name: 'wilson电信流量池',
                    jifei: 1,
                    fee: '',
                    chaofee: ''
                },
                rules: {
                    fee: [
                        { required: true, message: '请输入流量资费', trigger: 'blur' },
                    ],
                    chaofee: [
                        { required: true, message: '请输入超额流量资费', trigger: 'blur' },
                    ],
                }
            }
        },
         methods: {
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                if (valid) {
                    alert('submit!');
                } else {
                    console.log('error submit!!');
                    return false;
                }
                });
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
                this.$router.push({
                    path: `/agent_increase/${this.$route.params.id9}/traffic_pools`
                })
            }
        }
    }
</script>

<style scoped>

</style>